package com.bjtech.dao.ibatis;

import java.text.ParseException;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.ssi.dao.impl.BaseDaoSqlMapImpl;

import com.bjtech.dao.AssignMeterDataDao;
import com.bjtech.domain.AssignMeterData;
import com.bjtech.domain.query.AssignMeterDataQuerySpec;
import com.bjtech.web.action.management.JzqDataQuerySpec;

/**
 * @author wf
 *
 */
@Repository(value="assignMeterDataDao")
public class SqlMapAssignMeterDataDao extends BaseDaoSqlMapImpl<AssignMeterData> implements
		AssignMeterDataDao {

	public int insertMeterDatas(List<String> meterRecords,Long file_id) {
		int success_num=0;
		for(String meterRecord:meterRecords){
			if(meterRecord.split(",").length==16){
				AssignMeterData entity;
				try {
					entity = new AssignMeterData(meterRecord);
					entity.setFile_id(file_id);
					if(!entity.getSerious_num().endsWith("000")){//2块补零不算
						super.insertEntity(entity);
					}
					success_num++;
				} catch (ParseException e) {
					e.printStackTrace();
				}
			}
		}
		return success_num;
	}

	public void insertSjMeterDatas(List<AssignMeterData> dataList, long file_id) {
		for(AssignMeterData entity:dataList){
			entity.setFile_id(file_id);
			super.insertEntity(entity);
		}
	}

	public List selectJzqTjInfo(String jzqNum) {
		return super.getSqlMapClientTemplate().queryForList("selectJzqTjInfo",jzqNum);
	}

	public List selectJzqDataInfo(AssignMeterDataQuerySpec selectBean) {
		return super.getSqlMapClientTemplate().queryForList("selectJzqDataInfoAll",selectBean);
	}
}
